<template>
	<el-form  :model="outform":rules="rules" ref="outform" label-width="80px">
	
		<el-form-item label="病人号" prop="patientId">
			<el-select v-model="outform.patientId" placeholder="请选择">
			    <el-option
			      v-for="item in tableData"
			      :key="item.patientId"
			      :label="item.patientId"
			      :value="item.patientId">
			    </el-option>
			  </el-select>
		</el-form-item>

		<el-form-item label="外出原因" prop="outReason">
			<el-input v-model="outform.outReason"></el-input>
		</el-form-item>
		<el-form-item label="外出时间" prop="outTime">
			<el-date-picker
						      v-model="outform.outTime"
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">
						    </el-date-picker>
		</el-form-item>
		<el-form-item label="归来时间" prop="returnTime">
			<el-date-picker
						      v-model="outform.returnTime"
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">
						    </el-date-picker>
		</el-form-item>
		<el-form-item label="陪同人员" prop="company">
			<el-input v-model="outform.company"></el-input>
		</el-form-item>
		<el-form-item label="陪同关系" prop="relation">
			<el-input v-model="outform.relation"></el-input>
		</el-form-item>
		<el-form-item label="联系电话" prop="telphone">
			<el-input v-model="outform.telphone"></el-input>
		</el-form-item>

		<el-form-item label="登记时间">
			<el-input v-model="outform.realTime"></el-input>
		</el-form-item>
		
		
		<el-button type="primary" @click="doOutAdd('outform')">提交</el-button>
	</el-form>
</template>

<script>
	
	export default{
		name:'OutAdd',
		props:[
			'dialogVisible'
		],
		data(){
			return {
				tableData:[],
				
				
				outform:{
					patientId:'',
					outReason:'',
					outTime:'',
					returnTime:'',
					compay:'',
					relation:'',
					telphone:'',
					realTime:''
	
			},
			rules: {
			          patientId: [
			            { required: true, message: '请输入客户序号', trigger: 'blur' },
			          ],
			          outReason: [
			            { required: true, message: '请输入外出原因', trigger: 'blur' }
			          ],
					  outTime: [
					    { required: true, message: '请选择外出日期', trigger: 'change' }
					  ],
					  returnTime: [
					    { required: true, message: '请选择出生日期', trigger: 'change' }
					  ],
					  company: [
					         { required: true, message: '请输入陪同人员', trigger: 'blur' }
					     ],
					  relation: [
					    { required: true, message: '请输入陪同人员关系', trigger: 'blur' }
					  ],
					  telphone: [
					    { required: true, message: '请输入电话号', trigger: 'blur' },
						{ min: 11, max: 11, message: '长度在 11 个字符', trigger: 'blur' }
					  ],
					  
					  realTime: [
					              { type: 'date', required: true, message: '请选择登记日期', trigger: 'change' }
					            ],
					
			        }
																		
																		
			}
		},
		mounted(){
			 this.initPatient();
		},
		methods:{
			doOutAdd(outform){
				console.log(this.outform);
				
				this.$refs[outform].validate((valid) => {
				  if (valid) {	
					  
					this.getRequest("/out-registrate/insert",this.outform).then(resp=>{
					if(resp){
						this.$emit("update:dialogVisible",false);
						this.$emit("add")
					}else{
						Message.error({message:'保存失败'});
					}
				})
				
				
				  } else {
				    alert('error submit!!');
				    return false;
				  }
				});
				
			},
			initPatient(){
				this.getRequest('/patient/List').then(resp=>{
					if(resp){         
						this.tableData=resp;
						
					}
				})
			}
		}
	}
</script>

<style>
</style>
